//
//  AppUtility.h
//  weizhuan
//
//  Created by lixun on 13-8-1.
//  Copyright (c) 2013年 lixun. All rights reserved.
//


#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>

#define RGBCOLOR(r,g,b) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:1]
//判断设备是否IPHONE5

#define iPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO)


#define SAFE_RELEASE(x) [x release];x=nil
@interface AppUtility : NSObject

+ (AppUtility*)getInstance;
+ (NSString *)getCurrentDeviceModel;

#pragma mark for cache
+ (NSString *)getPathInDefaultDir:(NSString*)inPathName;
+ (NSString *)getDownloadPathInCache:(NSString*)inName;
+ (BOOL)downloadIsExistInCache:(NSString*)inName;
+ (NSString*)getDownloadPathInCacheWithURLStr:(NSString *)inURLStr;
+ (NSString *)getImagePathInCache:(NSString*)inImageName;
+ (NSString*)getImagePathInCacheWithURLStr:(NSString*)inURLStr;
+ (BOOL)imageIsExistInCache:(NSString*)inImageName;
+ (UIImage*)getImageInCacheWithURLStr:(NSString *)inURLStr;
+ (void)createDuiHuaCacheDir;
+ (NSString *)getFilePathInDuiHuaCache:(NSString*)fileName_;
+ (BOOL)fileIsExistInDuiHuaCache:(NSString*)fileName_;

#pragma mark for image
+ (UIImage*)getLocalImage:(NSString*)inImgName;
+ (UIImage*)getLocalJGPImage:(NSString*)inImgName;
+ (UIImage*)getLocalImageWithCache:(NSString*)inImgName;
+ (UIImage *)rotateImage:(UIImage *)aImage;
//+ (NSString*)getNetImagePathWithWidth:(int)width_ andHeight:(int)height_ andSrc:(NSString*)src_;
+ (CGSize)sizeFit:(CGSize)originSize toSize:(CGSize)maxSize;
+ (UIImage *)resizeImage:(UIImage*)image_ andSize:(CGSize)size_;

#pragma mark for device
+ (BOOL)isIPhone4;

#pragma mark for date
+ (NSDate *)stringToDate:(NSString *)string;
+ (NSString *)dateToString:(NSDate *)date;

#pragma mark for net progress
+ (void)showNetworkActivityIndicator:(BOOL)inShow;

#pragma mark for timeout
+ (BOOL)checkTimeOutWithStartTime:(NSString*)inStartTime andInterval:(double)inInterval;
+ (BOOL)checkTimeOutWithStartTime:(NSString*)inStartTime andNowTime:(NSString*)inNowTime andInterval:(NSTimeInterval)inInterval;

#pragma mark for custom
+ (UIColor*)getViewBGColor;
+ (UIColor*)getNavBarBGColor;
+ (UIButton*)getNavBtnLeftWith:(SEL)inSelector andTitle:(NSString*)inTitle andTarget:(id)inTarget;
+ (UIButton*)getNavBtnRightWith:(SEL)inSelector andTitle:(NSString*)inTitle andTarget:(id)inTarget;

+ (UIBarButtonItem*)getNavBtnItemLeftWith:(SEL)inSelector andTitle:(NSString*)inTitle andTarget:(id)inTarget andFont:(int)fontsize;
+ (UIBarButtonItem*)getNavBtnItemRightWith:(SEL)inSelector andTitle:(NSString*)inTitle andTarget:(id)inTarget andFont:(int)fontsize;



+ (UIBarButtonItem*)getNavBtnItemLefBacktWith:(SEL)inSelector andTarget:(id)inTarget;

+ (UIBarButtonItem*)getNavBackBtnItemWith:(SEL)inSelector andTitle:(NSString*)inTitle andTarget:(id)inTarget;
+ (UIBarButtonItem*)getDrawerNavBtnItemWith:(SEL)inSelector andTitle:(NSString*)inTitle andTarget:(id)inTarget;
+ (UIBarButtonItem*)getToolBtnItemLeftWith:(SEL)inSelector andTitle:(NSString*)inTitle andTarget:(id)inTarget;
+ (UIBarButtonItem*)getToolBtnItemRightWith:(SEL)inSelector andTitle:(NSString*)inTitle andTarget:(id)inTarget;

+ (UIBarButtonItem*)getNavBtnItemLeft1With:(SEL)inSelector andTitle:(NSString*)inTitle andTarget:(id)inTarget andFont:(int)fontsize;

//导航左右按钮的 图片设置

+ (UIBarButtonItem*)getNavBtnItemHomePersonWith:(SEL)inSelector andTarget:(id)inTarget;
+ (UIBarButtonItem*)getNavBtnItemHomeLeftWith:(SEL)inSelector andTarget:(id)inTarget;

+ (UIBarButtonItem*)getNavBtnItemRightWith:(SEL)inSelector andImageName_nomal:(NSString*)imageName_nomal andImageName_selected:(NSString *)imageName_selected andTarget:(id)inTarget andUIEdgeInsets:(UIEdgeInsets)uiEdgeInset andButtonSize:(CGSize)btnSize;


//导航左右按钮的 文字和图片设置

+ (UIBarButtonItem*)getNavBtnItemRightWith:(SEL)inSelector andImageName_nomal:(NSString*)imageName_nomal andImageName_selected:(NSString *)imageName_selected andTarget:(id)inTarget andImageEdgeInsets:(UIEdgeInsets)imageEdgeInset andWithTitle:(NSString *)title andWithTitleColor:(UIColor *)titleColor andWithTitleFont:(int)titleFont andTitleEdgeInset:(UIEdgeInsets)titleEdgeInset andButtonSize:(CGSize)btnSize;

+ (UIBarButtonItem*)getNavBtnItemLeftWith:(SEL)inSelector andImageName_nomal:(NSString*)imageName_nomal andImageName_selected:(NSString *)imageName_selected andTarget:(id)inTarget andImageEdgeInsets:(UIEdgeInsets )imageEdgeInset andWithTitle:(NSString *)title andWithTitleColor:(UIColor *)titleColor andWithTitleFont:(int)titleFont andTitleEdgeInset:(UIEdgeInsets)titleEdgeInset andButtonSize:(CGSize)btnSize;

//+ (UIBarButtonItem*)getNavBtnItemWith:(SEL)inSelector andNormalImgPath:(NSString*)inNormal andHovImgPath:(NSString*)inHov andTarget:(id)inTarget;

#pragma mark for rand num
+(int)getRand;

#pragma mark for check NSNull
+ (BOOL)isNotNSNull:(id)value_;

+(float)screenHeight;
+(float)screenWidth;

+(BOOL)isPhone;
+(NSString *)dayDayTimeWordToString:(NSTimeInterval )interval;
+(NSString *)dayDayWordToString:(NSTimeInterval )interval;
+(NSString *)dayHourWordToString:(NSTimeInterval )interval;
+(NSString *)dayHourWordToString1:(NSTimeInterval )interval;

+(NSString *)DelTimedayDayWordToString:(NSTimeInterval )interval;
+(NSString *)MonthAndDayWordToString:(NSTimeInterval )interval;
+(NSString *)OtherMonthAndDayWordToString:(NSTimeInterval )interval;
+(NSString *)AnotherMonthAndDayWordToString:(NSTimeInterval )interval;
+(NSString *)getYearAndMonthAndDay;
+(NSString *)getTimeFrom:(NSTimeInterval)interval;

+(BOOL)isIOS7;
+(BOOL)isIOS8;
+(BOOL)isIOS9;
+(BOOL)isIOS10;
+(NSString *)getWeekDay;
+(NSString *)getWeekDayFromTime:(NSTimeInterval )interval;
+(NSString *)getMonthAndDay;


+(NSString *)getXiTongYear;
+(NSString *)getXiTongMonth;
+(NSString *)getXiTongDay;
+(NSString *)getYearFromTimeInterval:(NSTimeInterval)interval;
+(NSString *)getMonthFromTimeInterval:(NSTimeInterval)interval;
+(NSString *)getDayFromTimeInterval:(NSTimeInterval)interval;

+(NSString *)getYearFromData:(NSDate*)date;
+(NSString *)getMonthFromData:(NSDate*)date;
+(NSString *)getDayFromData:(NSDate*)date;
+(NSString *)getNowDate;


+(BOOL)checkTel:(NSString *)str;

+(void)tellPhone:(NSString *)phone;

//字符串的长度
+(float)widthWithString:(NSString *)string WithFont:(int)font;

//字符冲的高度
+(float)heightForString:(NSString *)value fontSize:(float)fontSize andWidth:(float)width;


//根据经纬度算距离
+(NSString *)distanceBetweenOrderBylat1:(double)lat1 lat2:(double)lat2 lng1:(double)lng1 lng2:(double)lng2;

//程序中得到app的scheme
+(NSString *)getAppScheme;


//获得秘钥
+(NSString *)getSecretKeyWithAction:(NSString *)action WithUID:(NSString *)UID;

+(NSString *)getReleaseTime:(int)timeData;

+ (BOOL)isBlankString:(NSString *)string;

+ (BOOL)isContainsEmoji:(NSString *)string;


+(NSString *)noBlankMyDic:(NSMutableDictionary *)myDic theKey:(NSString *)key;

+ (BOOL)validateIDCardNumber:(NSString *)value;

+(NSData *)Image_TransForm_Data:(UIImage *)image;


+(BOOL)isValidateEmail:(NSString *)email;

//是否为数字
+(BOOL)validateNumber:(NSString*)number;
+(void)reSetViewFrame:(UIView *)view;
+(BOOL)judgePassWordLegal:(NSString *)pass;
+(BOOL)judgePassWordLegal1:(NSString *)pass;

+ (NSString *) compareCurrentTime:(NSString *)str;
+ (NSString *) compareCurrentTime1:(NSString *)str;
- (NSString *)updateTimeForRow:(NSString *)createTimeString;
@end
